<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/config.inc.php');
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/top.inc.php');

$course_id = mysql_real_escape_string(strip_tags($_POST['cid']));
$subject_id = mysql_real_escape_string(strip_tags($_POST['sid']));
$section_id = mysql_real_escape_string(strip_tags($_POST['sec_id']));
$csm_id = mysql_real_escape_string(strip_tags($_POST['csm_id']));
$section_number = mysql_real_escape_string(strip_tags($_POST['section_num']));
$instructor_id = mysql_real_escape_string(strip_tags($_POST['instructor']));
$room_type_id = mysql_real_escape_string(strip_tags($_POST['room_type']));
$max_students = mysql_real_escape_string(strip_tags($_POST['max_s']));
$honors = mysql_real_escape_string(strip_tags($_POST['honors']));
$semester_id = mysql_real_escape_string(strip_tags($_POST['semester']));

$get_subject_data = mysql_query("SELECT * FROM course_subjects WHERE id = $subject_id");
$subject_name = mysql_result($get_subject_data,0,'subject_title');
$abbreviation = mysql_result($get_subject_data,0,'abbreviation');

$get_course_data = mysql_query("SELECT * FROM courses WHERE id = $course_id");
$course_number = mysql_result($get_course_data,0,'course_number');
$course_name = mysql_result($get_course_data,0,'title');

echo "<h1>Edit Section for $abbreviation $course_number</h1>";

$section_query = "UPDATE course_sections
					SET section_number='$section_number',
						semester_id='$semester_id',
						instructor_id='$instructor_id',
						classroom_type_id='$room_type_id',
						num_seats='$max_students',
						honors_program='$honors'
					WHERE id='$section_id'";
		
$section_result = mysql_query($section_query);
		
if ($section_result)
{
	echo "Section <b>$section_number</b> has been successfully Updated!";
	echo "<br />";
}
else
{
	echo "Section <b>$section_number</b> was NOT able to be updated at this time!";
	echo "<br />";
}
;

echo "<p>";
	echo "<a href='index.php?sid=$subject_id&id=$course_id'>&lt;&lt; Back to Sections Portal</a><br />";
echo "</p>";

?>

<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/bottom.inc.php');
?>